package com.xinfu.newproject.adapter.complaint_adapter;

import android.os.Bundle;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.gson.Gson;
import com.xinfu.newproject.R;
import com.xinfu.newproject.activity.ComplaintFeedbackActivity;
import com.xinfu.newproject.bean.complaint.bean.ComplaintRecordBean;
import com.xinfu.newproject.ui.complaint_feedback.ComplaintDetailsFragment;


/**
 *
 */
public class ComplaintListAdapter extends BaseQuickAdapter<ComplaintRecordBean.ResultBean, BaseViewHolder> {

    TextView nameTv, timeTv, priceTv, carId;

    public ComplaintListAdapter() {
        super(R.layout.item_complaint_list, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, ComplaintRecordBean.ResultBean item) {
        switch (item.getStatus()) {
            case 100:
                helper.setText(R.id.item_complaint_list_status_tv, "待受理");
                helper.setTextColor(R.id.item_complaint_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
            case 200:
                helper.setText(R.id.item_complaint_list_status_tv, "待评价");
                helper.setTextColor(R.id.item_complaint_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                break;
            case 300:
                helper.setText(R.id.item_complaint_list_status_tv, "已评价");
                helper.setTextColor(R.id.item_complaint_list_status_tv, mContext.getResources().getColor(R.color.colorAccent));
                break;
            case 400:
                helper.setText(R.id.item_complaint_list_status_tv, "待受理");
                helper.setTextColor(R.id.item_complaint_list_status_tv, mContext.getResources().getColor(R.color.blue_4a));
                break;
        }


        helper.setText(R.id.item_complaint_list_time_tv, item.getCreateTime());
        helper.setText(R.id.item_complaint_list_content_tv, item.getContent());
        helper.setText(R.id.item_complaint_list_type_name_tv, item.getProjectName());

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("response", new Gson().toJson(item));
                ((ComplaintFeedbackActivity) mContext).startIntentActivity(ComplaintDetailsFragment.class, bundle);
            }
        });
    }

    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View widget) {
//            ToastUtils.showShortToast("事件触发了 landscapes and nedes");
        }

        @Override
        public void updateDrawState(TextPaint ds) {
//            ds.setColor(Utils.getContext().getResources().getColor(R.color.clickspan_color));
//            ds.setUnderlineText(true);
        }
    };


}
